//package com.info.zhiduoduo.pay.service;
//
//import com.alibaba.fastjson.JSON;
//import com.info.zhiduoduo.common.configs.DaysPayConfig;
//import com.info.zhiduoduo.common.constants.SmartResult;
//import com.info.zhiduoduo.common.constants.StatusMsg;
//import com.info.zhiduoduo.common.exception.Asserts;
//import com.info.zhiduoduo.pay.sdk.dayspaysdk.model.pay.request.PayReqDTO;
//import com.info.zhiduoduo.pay.sdk.dayspaysdk.model.pay.request.QueryMerchantBalanceReqDTO;
//import com.info.zhiduoduo.pay.sdk.dayspaysdk.model.pay.request.QueryPayReqDTO;
//import com.info.zhiduoduo.pay.sdk.dayspaysdk.model.pay.response.PayResDTO;
//import com.info.zhiduoduo.pay.sdk.dayspaysdk.model.pay.response.QueryMerchantBalanceResDTO;
//import com.info.zhiduoduo.pay.sdk.dayspaysdk.model.pay.response.QueryPayResDTO;
//import com.info.zhiduoduo.pay.sdk.dayspaysdk.service.DaysPayApiService;
//import com.info.zhiduoduo.pay.formbean.dayspay.DaysAgentPayFormBean;
//import com.info.zhiduoduo.pay.formbean.dayspay.DaysQueryAgentPayFormBean;
//import com.info.zhiduoduo.repository.entity.pay.PaymentMerchant;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.time.LocalTime;
//
//import lombok.extern.slf4j.Slf4j;
//
//@Slf4j
//@Service
//public class DaysPayService {
//
//	@Autowired
//	DaysPayApiService daysPayApiService;
//
//	@Autowired
//	DaysPayConfig daysPayConfig;
//
//	public SmartResult<PayResDTO> agentPay(DaysAgentPayFormBean formBean) {
//		// 支付加时间段限制22:50-23:00，01:00-05:00
//		LocalTime now = LocalTime.now();
//		LocalTime periodStart1 = LocalTime.of(22, 50);
//		LocalTime periodEnd1 = LocalTime.of(23, 0);
//		LocalTime periodStart2 = LocalTime.of(1, 0);
//		LocalTime periodEnd2 = LocalTime.of(5, 0);
//		Asserts.isTrue((now.isBefore(periodStart1) || now.isAfter(periodEnd1)) && (now.isBefore(periodStart2) || now.isAfter(periodEnd2)),
//				StatusMsg.StatusMsg_460);
//
//		PaymentMerchant paymentMerchant = new PaymentMerchant().selectById(formBean.getPaymentMerchant());
//		log.info("获取到的支付商户号:{}", JSON.toJSONString(paymentMerchant));
//		Asserts.notNull(paymentMerchant, StatusMsg.StatusMsg_459);
////		if (paymentMerchant.getId() == DaysMerchantType.WUSHENG) {
////			// 武圣 每笔限额35000
////			Asserts.isTrue(formBean.getTradeamount().doubleValue() <= 35000, StatusMsg.StatusMsg_461);
////		}
//
//		PayReqDTO payReqDTO = PayReqDTO.of(formBean).setMerchantNo(paymentMerchant.getMerchantNo());
//		PayResDTO payResDTO = daysPayApiService.agentPay(payReqDTO, paymentMerchant);
//		if (payResDTO == null) {
//			return SmartResult.fail(StatusMsg.StatusMsg_457);
//		} else {
//			return SmartResult.success(payResDTO);
//		}
//	}
//
//	public SmartResult<QueryPayResDTO> queryAgentPay(DaysQueryAgentPayFormBean formBean) {
//		PaymentMerchant paymentMerchant = new PaymentMerchant().selectById(formBean.getMerchantId());
//		Asserts.notNull(paymentMerchant, StatusMsg.StatusMsg_459);
//
//		QueryPayReqDTO queryPayReqDTO = QueryPayReqDTO.of(formBean).setMerchantNo(paymentMerchant.getMerchantNo());
//		QueryPayResDTO payResDTO = daysPayApiService.queryAgentPay(queryPayReqDTO, paymentMerchant);
//		if (payResDTO == null) {
//			return SmartResult.fail(StatusMsg.StatusMsg_458);
//		} else {
//			return SmartResult.success(payResDTO);
//		}
//	}
//
//	public SmartResult<QueryMerchantBalanceResDTO> queryMerchantBalance(int daysMerchantId) {
//		PaymentMerchant paymentMerchant = new PaymentMerchant().selectById(daysMerchantId);
//		Asserts.notNull(paymentMerchant, StatusMsg.StatusMsg_459);
//
//		QueryMerchantBalanceReqDTO reqDTO = QueryMerchantBalanceReqDTO.of().setMerchantNo(paymentMerchant.getMerchantNo());
//		QueryMerchantBalanceResDTO resDTO = daysPayApiService.queryMerchantBalance(reqDTO, paymentMerchant);
//		if (resDTO == null) {
//			return SmartResult.fail(StatusMsg.StatusMsg_458);
//		} else {
//			return SmartResult.success(resDTO);
//		}
//	}
//}
